﻿package plugin.gameHall.game
{
    import com.core.*;
    import flash.external.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.gameHall.*;
    import plugin.platform.*;
    import uiresource.gameHall.*;
    import view.component.*;
    import view.mornExtends.*;
    import vo.*;

    public class GameHallRewardCon extends GameHallRewardUI
    {
        private var _instance:GameHallReward;

        public function GameHallRewardCon(param1:GameHallReward)
        {
            this._instance = param1;
            return;
        }// end function

        override protected function initializeView() : void
        {
            var _loc_1:* = Control.create(GameHallRewardControl, this);
            ModelProxy.addObserver("gameHall", _loc_1);
            this.showItem();
            this.initEvent();
            return;
        }// end function

        private function initEvent() : void
        {
            btn_colse.clickHandler = new Handler(this.doClick);
            btn_lingqu.clickHandler = new Handler(this.checkLq);
            return;
        }// end function

        private function checkLq() : void
        {
            if (ExternalInterface.call("wan360.Is360Game"))
            {
                PlatformSender._5360Hall();
            }
            else
            {
                PluginManager.instance.open("gameHall");
            }
            return;
        }// end function

        public function listFly() : void
        {
            ListFly.go(itemlist, new Handler(this._instance.close));
            return;
        }// end function

        private function doClick() : void
        {
            this._instance.close();
            return;
        }// end function

        private function showItem() : void
        {
            var _loc_6:String = null;
            var _loc_7:Array = null;
            var _loc_8:Object = null;
            var _loc_1:* = ConfigDictionary.data.box;
            var _loc_2:* = ConfigDictionary.data.item;
            var _loc_3:Array = [];
            var _loc_4:* = (_loc_1[240702356].items as String).split(";");
            var _loc_5:int = 0;
            while (_loc_5 < _loc_4.length)
            {
                
                _loc_6 = _loc_4[_loc_5];
                _loc_7 = _loc_6.split("-");
                if (_loc_7.length >= 4)
                {
                    if (_loc_7[3] != 2 && _loc_7[3] != ModelProxy.getValue("data", "user.sex"))
                    {
                        ;
                    }
                }
                if (_loc_7.length >= 5)
                {
                    if (_loc_7[4] != 0 && _loc_7[4] != ModelProxy.getValue("data", "user.career"))
                    {
                        ;
                    }
                }
                _loc_8 = ItemObject.create(_loc_2[_loc_7[0]]);
                _loc_8.count = _loc_7[1];
                _loc_3.push(_loc_8);
                _loc_5++;
            }
            itemlist.array = _loc_3;
            itemlist.renderHandler = new Handler(this.itemRender);
            return;
        }// end function

        private function itemRender(param1:Component, param2:int) : void
        {
            if (param2 < itemlist.length)
            {
                (param1 as FlashItem).data = itemlist.array[param2];
            }
            return;
        }// end function

    }
}
